# $Id: PKGBUILD 84354 2013-02-16 22:50:32Z ioni $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer:Biginoz < biginoz AT free point fr>
# Contributor: Ignacio Galmarino <igalmarino@gmail.com>
# Contributor: Matthias Sobczyk <matthias.sobczyk@googlemail.com>
# Contributor: Kamil Kaminski <kyle@kkaminsk.com>

pkgname=minidlna
pkgver=1.0.25
pkgrel=5
pkgdesc="A DLNA/UPnP-AV Media server (aka ReadyDLNA)"
arch=('i686' 'x86_64')
url="http://sourceforge.net/projects/minidlna/"
license=('GPL')
depends=('libexif' 'libjpeg' 'libid3tag' 'flac' 'libvorbis' 'ffmpeg' 'sqlite')
backup=('etc/minidlna.conf'
	'etc/conf.d/minidlna')
install=minidlna.install
changelog=changelog
source=(http://downloads.sourceforge.net/minidlna/minidlna_${pkgver}_src.tar.gz
	minidlna.rc
	minidlna.service
	minidlna.tmpfiles)
md5sums=('d966256baf2f9b068b9de871ab5dade5'
         '1b92f88905abe8f719585d48f4b25a49'
         '1903ed9ceee43b8bb86146b9ad8eb50c'
         '26de27b12d6a37c47d9714107d07aac9')

build() {
  cd "$srcdir/$pkgname-$pkgver"
  sed -i 's|DB_PATH=.*|DB_PATH=/var/cache/minidlna|' genconfig.sh
  find -type f -name '*.c' -exec sed -i '1,1i#include </usr/include/time.h>' {} \;
  make
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  DESTDIR=$pkgdir make install
  install -Dm644 minidlna.conf ${pkgdir}/etc/minidlna.conf

  install -Dm755 ${srcdir}/minidlna.rc ${pkgdir}/etc/rc.d/minidlna
  mkdir -p $pkgdir/etc/conf.d
  echo 'MINIDLNA_USER=nobody' >$pkgdir/etc/conf.d/minidlna
  echo 'MINIDLNA_OPTS=""' >>$pkgdir/etc/conf.d/minidlna

  # systemd files
  install -Dm0644 $srcdir/minidlna.tmpfiles $pkgdir/usr/lib/tmpfiles.d/minidlna.conf
  install -Dm0644 $srcdir/minidlna.service $pkgdir/usr/lib/systemd/system/minidlna.service
}
